package com.sdehl.kafkatransfer.constant.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * @author Jiax
 * @version 1.0.0
 * @description: PlateColorEnum
 * @date 2023-10-13 14:52
 */
@Getter
public enum PlateColorEnum {

    WHITE(0,"白色","white"),
    YELLOW(1,"黄色","yellow"),
    BULE(2,"蓝色","blue"),
    BLACK(3,"黑色","black"),
    OTHER(4,"其他","other"),
    ;
    /**
     * 编码
     */
    private Integer code;
    /**
     * 中文名称
     */
    private String name;
    /**
     * 英文名称
     */
    private String enName;


    PlateColorEnum(Integer code, String name, String enName) {
        this.code = code;
        this.name = name;
        this.enName = enName;
    }

    /**
     * 根据code查询车牌颜色枚举
     * @param code
     * @return
     */
    public static PlateColorEnum getByCode(Integer code) {
        for (PlateColorEnum plateColor : values()) {
            if (Objects.equals(plateColor.getCode(), code)) {
                return plateColor;
            }
        }
        return null;
    }

    /**
     * 根据code查询车牌颜色枚举
     * @param code
     * @return
     */
    public static String getEnNameByCode(Integer code) {
        for (PlateColorEnum plateColor : values()) {
            if (Objects.equals(plateColor.getCode(), code)) {
                return plateColor.getEnName();
            }
        }
        return null;
    }

}
